load("@fbcode_macros//build_defs:cpp_binary.bzl", "cpp_binary")
load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")
load("//fboss:THIRD-PARTY-VERSIONS.bzl", "SAI_BRCM_DNX_IMPLS")
load("//fboss/agent/hw/sai/impl:impl.bzl", "get_link_group_map", "to_impl_bin_name", "to_impl_lib_name")
load("//fboss/agent/hw/sai/switch:switch.bzl", "sai_switch_dependent_name")

oncall("fboss_agent_push")

cpp_library(
    name = "agent_multinode_test_src",
    srcs = [
        "AgentMultiNodeDsfTest.cpp",
        "AgentMultiNodeDsfUtils.cpp",
        "AgentMultiNodeProcessRestartTest.cpp",
        "AgentMultiNodeTest.cpp",
        "AgentMultiNodeUtils.cpp",
        "AgentMultiNodeVoqSwitchNeighborTests.cpp",
        "AgentMultiNodeVoqSwitchNoTrafficDropsTests.cpp",
        "AgentMultiNodeVoqSwitchTests.cpp",
        "AgentMultiNodeVoqSwitchTrafficTests.cpp",
        "DsfTopologyInfo.cpp",
        "TopologyInfo.cpp",
    ],
    headers = [
        "AgentMultiNodeDsfUtils.h",
        "AgentMultiNodeTest.h",
        "AgentMultiNodeUtils.h",
        "AgentMultiNodeVoqSwitchNeighborTests.h",
        "AgentMultiNodeVoqSwitchTrafficTests.h",
        "DsfTopologyInfo.h",
    ],
    link_whole = True,
    exported_deps = [
        "fbsource//third-party/googletest:gtest",
        "//common/network:util",
        "//fboss/agent:asic_utils",
        "//fboss/agent:core",
        "//fboss/agent:fboss-types",
        "//fboss/agent/if:common-cpp2-types",
        "//fboss/agent/if:hw_ctrl-cpp2-services",
        "//fboss/agent/packet:packet_factory",
        "//fboss/agent/state:state",
        "//fboss/agent/test:agent_hw_test",
        "//fboss/agent/test/thrift_client_utils:thrift_client_utils",
        "//fboss/agent/test/utils:load_balancer_test_utils",
        "//fboss/lib:common_utils",
        "//folly:network_address",
    ],
)

_sai_agent_multinode_test_prefix = "sai_agent_multinode_test"

[
    cpp_binary(
        name = to_impl_bin_name(sai_impl, _sai_agent_multinode_test_prefix),
        srcs = [
            "SaiAgentMultiNodeMain.cpp",
        ],
        link_group_map = get_link_group_map(
            to_impl_bin_name(sai_impl, _sai_agent_multinode_test_prefix),
            sai_impl,
        ),
        linker_flags = [],
        versions = {
            sai_impl.sdk_name: sai_impl.version,
        },
        deps = [
            "fbsource//third-party/googletest:gtest",
            ":agent_multinode_test_src",
            "//fboss/agent:main-sai-{}".format(to_impl_lib_name(sai_impl)),
            "//fboss/agent/platforms/sai:{}".format(sai_switch_dependent_name("sai_platform", sai_impl, True)),
            "//fboss/agent/test:mono_agent_ensemble",
            "//fboss/agent/hw/sai/hw_test:{}".format(sai_switch_dependent_name("agent_hw_test_thrift_handler", sai_impl, True)),
            "//fboss/agent:setup_thrift_test",
            "//fboss/agent/test:agent_hw_test",
        ],
    )
    for sai_impl in SAI_BRCM_DNX_IMPLS
]
